package com.tarena.rocketmq.study.consumer;

import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(
        topic = "test-01-topic",
        consumerGroup = "${rocketmq.consumer.group}",
        selectorExpression = "*"
)
//接口的泛型 对应发送时 消息封装payLoad的类型
public class MyConsumer01 implements RocketMQListener<String> {
    /**
     * @param message 是payLoad反序列化结果
     * 底层是一个MessageListenerCurrently监听器 需要返回值
     * CONSUME_SUCCESS RECONSUME_LATER
     * 如果onMessage没有向外抛出异常,底层返回结果就是   CONSUME_SUCCESS
     * 如果onMessage 底层返回结果就是 RECONSUME_LATER(消息会被重复消费 retry)
     */
    @Override
    public void onMessage(String message) {
        System.out.println("消费者01框架消费监听 拿到消息:"+message);
    }
}
